package com.cola.Comparable;

/**
 * @Grup:com.cola.Comparable
 * @Auther:cola
 * @Data:2021/3/16-2021-03-16:04
 * @version:1.0
 * 自定义
 */
public class Cat implements Comparable<Cat>{
    private String name;
    private int age;

    public Cat() {
        super();
    }

    @Override
    public String toString() {
        return "Cat{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public Cat(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public int compareTo(Cat o) {
        /*if (this.age<o.age)return -1;
        if (this.age>o.age)return 1;
        return 0;*/
        return this.age-o.age;
    }
}
